package com.xuyiwei.mayi.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by xuyiwei on 2019/4/23.
 */
@RestController
public class MemberController {

    @RequestMapping("/getUserList")
    public List<String> getUserList() {
        List<String> listUser = new ArrayList<String>();
        listUser.add("zhangsan");
        listUser.add("lisi");
        listUser.add("yushengjun");
        return listUser;
    }

    @RequestMapping("/getPort")
    public String getPort() {
        ServletRequestAttributes requestAttributes =(ServletRequestAttributes)RequestContextHolder.getRequestAttributes();
        int port = requestAttributes.getRequest().getLocalPort();
        return "这里是端口号"+port+"";
    }

}